﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace ChuyenLenhSanXuat
{
    public class ChuyenLenhSX
    {
        AccessData ac = new AccessData();
        public int themlenhsx(string solsx, string masp, string mamau, string msm, int coso, int soluong, string ngaytn, string makh, string soddh, string ngaygh, string ngaykiem, string ghichu)
        {
            SqlParameter[] arrPara = new SqlParameter[12];
            arrPara[0] = new SqlParameter("@SoLSXinput", SqlDbType.VarChar);
            arrPara[0].Value = solsx;
            arrPara[1] = new SqlParameter("@MaSP", SqlDbType.VarChar);
            arrPara[1].Value = masp;
            arrPara[2] = new SqlParameter("@MA_MAU", SqlDbType.VarChar);
            arrPara[2].Value = mamau;
            arrPara[3] = new SqlParameter("@MSM_Bacod", SqlDbType.VarChar);
            arrPara[3].Value = msm;
            arrPara[4] = new SqlParameter("@CoSo", SqlDbType.Int);
            arrPara[4].Value = coso;
            arrPara[5] = new SqlParameter("@SoLuong", SqlDbType.Int);
            arrPara[5].Value = soluong;
            arrPara[6] = new SqlParameter("@NgayTN", SqlDbType.VarChar);
            arrPara[6].Value = ngaytn;
            arrPara[7] = new SqlParameter("@MaKH", SqlDbType.VarChar);
            arrPara[7].Value = makh;
            arrPara[8] = new SqlParameter("@SoDDH", SqlDbType.VarChar);
            arrPara[8].Value = soddh;
            arrPara[9] = new SqlParameter("@NgayGH", SqlDbType.VarChar);
            arrPara[9].Value = ngaygh;
            arrPara[10] = new SqlParameter("@NgayKiem", SqlDbType.VarChar);
            arrPara[10].Value = ngaykiem;
            arrPara[11] = new SqlParameter("@GhiChu", SqlDbType.VarChar);
            arrPara[11].Value = ghichu;
            DataTable dt = ac.ftblDocDuLieuSP("thuan_chuyenlsx", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int golenhsx(string solsx)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@SoLSXinput", SqlDbType.VarChar);
            arrPara[0].Value = solsx;
            DataTable dt = ac.ftblDocDuLieuSP("thuan_golenhsx", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int updatelanchiettinh(string solsx)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@solsx", SqlDbType.VarChar);
            arrPara[0].Value = solsx;
            DataTable dt = ac.ftblDocDuLieuSP("updatelanchiettinh", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public DataTable chuyenlsx_loi(string solsx)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@SoLSXinput", SqlDbType.VarChar);
            arrPara[0].Value = solsx;
            return ac.ftblDocDuLieuSP("thuan_chuyenlsx_loi", arrPara);
        }
        public DataTable loadgrid(string solsx)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@SoLSXinput", SqlDbType.VarChar);
            arrPara[0].Value = solsx;
            return ac.ftblDocDuLieuSP("Thuan_LoadGrid", arrPara);
        }
        public int updatemau(string solsx)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@SoLSXinput", SqlDbType.VarChar);
            arrPara[0].Value = solsx;
            DataTable dt = ac.ftblDocDuLieuSP("thuan_chuyenlsx_updatemsm ", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int ktralsx(string solsx)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@SoLSXinput", SqlDbType.VarChar);
            arrPara[0].Value = solsx;
            DataTable dt = ac.ftblDocDuLieuSP("thuan_chuyenlsx_kt", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public int xoalsx(string solsx)
        {
            SqlParameter[] arrPara = new SqlParameter[1];
            arrPara[0] = new SqlParameter("@SoLSXinput", SqlDbType.VarChar);
            arrPara[0].Value = solsx;
            DataTable dt = ac.ftblDocDuLieuSP("thuan_chuyenlsx_xoa", arrPara);
            return int.Parse(dt.Rows[0]["ErrCode"].ToString());
        }
        public DataTable loadlenhxoa()
        {

            return ac.ftblDocDuLieuSP("Thuan_LoadXoa", null);
        }
        public DataTable loadlenhmoi()
        {

            return ac.ftblDocDuLieuSP("Thuan_LoadLenhMoi", null);
        }
    }
}
